#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
//http://oj33.cn/contest.php?cid=1075
//https://blog.csdn.net/qq_37482202/article/details/89513877
int board[1005][1005];
const int Max = 10000;
int vis[Max];
int n;
void DFS(int x)
{
	cout << x << " ";
	for (int i = 0; i < n; i++)
	{
		if (!vis[i] && board[i][x])
		{
			vis[i] = 1;
			DFS(i);
		}
	}
}
int main()
{
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin >> board[i][j];
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (!vis[i])
		{
			vis[i] = 1;
			DFS(i);
			cout << endl;
		}
		
	}



	return 0;
}